1use crate::co;
2use crate::comctl::privs::*;
3use crate::decl::*;
4use crate::msg::*;
5use crate::prelude::*;
6use crate::user::privs::*;
7
8pub struct PbmDeltaPos {
13 pub advance_amount: u32,
14}
15
16impl MsgSend for PbmDeltaPos {
17 type RetType = u32;
18
19 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
20 v as _
21 }
22
23 fn as_generic_wm(&mut self) -> Wm {
24 Wm {
25 msg_id: co::PBM::DELTAPOS.into(),
26 wparam: self.advance_amount as _,
27 lparam: 0,
28 }
29 }
30}
31
32pub struct PbmGetBarColor {}
37
38impl MsgSend for PbmGetBarColor {
39 type RetType = Option<COLORREF>;
40
41 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
42 match v as u32 {
43 CLR_DEFAULT => None,
44 v => Some(unsafe { COLORREF::from_raw(v) }),
45 }
46 }
47
48 fn as_generic_wm(&mut self) -> Wm {
49 Wm {
50 msg_id: co::PBM::GETBARCOLOR.into(),
51 wparam: 0,
52 lparam: 0,
53 }
54 }
55}
56
57pub struct PbmGetBkColor {}
62
63impl MsgSend for PbmGetBkColor {
64 type RetType = Option<COLORREF>;
65
66 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
67 match v as u32 {
68 CLR_DEFAULT => None,
69 v => Some(unsafe { COLORREF::from_raw(v) }),
70 }
71 }
72
73 fn as_generic_wm(&mut self) -> Wm {
74 Wm {
75 msg_id: co::PBM::GETBKCOLOR.into(),
76 wparam: 0,
77 lparam: 0,
78 }
79 }
80}
81
82pub struct PbmGetPos {}
87
88impl MsgSend for PbmGetPos {
89 type RetType = u32;
90
91 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
92 v as _
93 }
94
95 fn as_generic_wm(&mut self) -> Wm {
96 Wm {
97 msg_id: co::PBM::GETPOS.into(),
98 wparam: 0,
99 lparam: 0,
100 }
101 }
102}
103
104pub struct PbmGetRange<'a> {
109 pub return_low: bool,
110 pub ranges: Option<&'a mut PBRANGE>,
111}
112
113impl<'a> MsgSend for PbmGetRange<'a> {
114 type RetType = i32;
115
116 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
117 v as _
118 }
119
120 fn as_generic_wm(&mut self) -> Wm {
121 Wm {
122 msg_id: co::PBM::GETRANGE.into(),
123 wparam: self.return_low as _,
124 lparam: self.ranges.as_mut().map_or(0, |r| r as *mut _ as _),
125 }
126 }
127}
128
129pub struct PbmGetState {}
134
135impl MsgSend for PbmGetState {
136 type RetType = co::PBST;
137
138 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
139 unsafe { co::PBST::from_raw(v as _) }
140 }
141
142 fn as_generic_wm(&mut self) -> Wm {
143 Wm {
144 msg_id: co::PBM::GETSTATE.into(),
145 wparam: 0,
146 lparam: 0,
147 }
148 }
149}
150
151pub struct PbmGetStep {}
156
157impl MsgSend for PbmGetStep {
158 type RetType = u32;
159
160 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
161 v as _
162 }
163
164 fn as_generic_wm(&mut self) -> Wm {
165 Wm {
166 msg_id: co::PBM::SETSTEP.into(),
167 wparam: 0,
168 lparam: 0,
169 }
170 }
171}
172
173pub struct PbmSetBarColor {
178 pub color: Option<COLORREF>,
179}
180
181impl MsgSend for PbmSetBarColor {
182 type RetType = Option<COLORREF>;
183
184 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
185 match v as u32 {
186 CLR_DEFAULT => None,
187 v => Some(unsafe { COLORREF::from_raw(v) }),
188 }
189 }
190
191 fn as_generic_wm(&mut self) -> Wm {
192 Wm {
193 msg_id: co::PBM::SETBARCOLOR.into(),
194 wparam: self.color.map_or(CLR_DEFAULT, |color| color.into()) as _,
195 lparam: 0,
196 }
197 }
198}
199
200pub struct PbmSetBkColor {
205 pub color: Option<COLORREF>,
206}
207
208impl MsgSend for PbmSetBkColor {
209 type RetType = Option<COLORREF>;
210
211 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
212 match v as u32 {
213 CLR_DEFAULT => None,
214 v => Some(unsafe { COLORREF::from_raw(v) }),
215 }
216 }
217
218 fn as_generic_wm(&mut self) -> Wm {
219 Wm {
220 msg_id: co::PBM::SETBKCOLOR.into(),
221 wparam: self.color.map_or(CLR_DEFAULT, |color| color.into()) as _,
222 lparam: 0,
223 }
224 }
225}
226
227pub struct PbmSetMarquee {
232 pub turn_on: bool,
233 pub time_ms: Option<u32>,
234}
235
236impl MsgSend for PbmSetMarquee {
237 type RetType = ();
238
239 unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
240 ()
241 }
242
243 fn as_generic_wm(&mut self) -> Wm {
244 Wm {
245 msg_id: co::PBM::SETMARQUEE.into(),
246 wparam: self.turn_on as _,
247 lparam: self.time_ms.unwrap_or(0) as _,
248 }
249 }
250}
251
252pub struct PbmSetPos {
257 pub position: u32,
258}
259
260impl MsgSend for PbmSetPos {
261 type RetType = u32;
262
263 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
264 v as _
265 }
266
267 fn as_generic_wm(&mut self) -> Wm {
268 Wm {
269 msg_id: co::PBM::SETPOS.into(),
270 wparam: self.position as _,
271 lparam: 0,
272 }
273 }
274}
275
276pub struct PbmSetRange {
281 pub min: u16,
282 pub max: u16,
283}
284
285impl MsgSend for PbmSetRange {
286 type RetType = SysResult<(u16, u16)>;
287
288 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
289 zero_as_badargs(v).map(|v| (LOWORD(v as _), HIWORD(v as _)))
290 }
291
292 fn as_generic_wm(&mut self) -> Wm {
293 Wm {
294 msg_id: co::PBM::SETRANGE.into(),
295 wparam: 0,
296 lparam: MAKEDWORD(self.min, self.max) as _,
297 }
298 }
299}
300
301pub struct PbmSetRange32 {
306 pub min: u32,
307 pub max: u32,
308}
309
310impl MsgSend for PbmSetRange32 {
311 type RetType = ();
312
313 unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
314 ()
315 }
316
317 fn as_generic_wm(&mut self) -> Wm {
318 Wm {
319 msg_id: co::PBM::SETRANGE32.into(),
320 wparam: self.min as _,
321 lparam: self.max as _,
322 }
323 }
324}
325
326pub struct PbmSetState {
331 pub state: co::PBST,
332}
333
334impl MsgSend for PbmSetState {
335 type RetType = co::PBST;
336
337 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
338 unsafe { co::PBST::from_raw(v as _) }
339 }
340
341 fn as_generic_wm(&mut self) -> Wm {
342 Wm {
343 msg_id: co::PBM::SETSTATE.into(),
344 wparam: self.state.raw() as _,
345 lparam: 0,
346 }
347 }
348}
349
350pub struct PbmSetStep {
355 pub step: u32,
356}
357
358impl MsgSend for PbmSetStep {
359 type RetType = u32;
360
361 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
362 v as _
363 }
364
365 fn as_generic_wm(&mut self) -> Wm {
366 Wm {
367 msg_id: co::PBM::SETSTEP.into(),
368 wparam: self.step as _,
369 lparam: 0,
370 }
371 }
372}
373
374pub struct PbmStepIt {}
379
380impl MsgSend for PbmStepIt {
381 type RetType = u32;
382
383 unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
384 v as _
385 }
386
387 fn as_generic_wm(&mut self) -> Wm {
388 Wm {
389 msg_id: co::PBM::STEPIT.into(),
390 wparam: 0,
391 lparam: 0,
392 }
393 }
394}